<script>
    nmenuindex=3;
	
</script>
        <div style="width: 960px;background: url(JO_images/hr.gif1) repeat-x top left #222;position: relative;float:left;

             ">
             <? include 'JO_007_nav1.php';
			 	$path="C:/xampp/htdocs/00_JO/JOi/";
 				include_once( $path."DataProvider/DataProvider.php" );
				include_once( $path."JO_02_function.php"		);
				if(isset($_GET['SO_chude']))
				if($_GET['SO_chude']!='')
				$chude=$_GET['SO_chude'];
				
				
	function test(){
		$s_SQLCommand = "call test();";
		$data=array();
		$rs_result = DataProvider::executeSQL($s_SQLCommand);
		while($rows=$rs_result->fetch_array()){
			array_push($data,$rows);
		}
		return $data; 
	}
	$result=test();
	$_S="";
	function getchild($arr,$key){	/*lay ra những topic con của 1,2		*/						
            $_S="";
		return getchild_($arr,$key,$_S);
		
	}
        function getchild_($arr,$key,$_S){	/*lay ra những topic con của 1,2		*/
	for($i=0;$i<count($arr);$i++){
			if($arr[$i][1]==$key){
				$_S.=getchild($arr,$arr[$i][0]);
				}
		}
		return $key.";".$_S;

	}
	function JO_news_relate_getlist($topic,$tag,$key){
		$result=test();
		$kq=";".getchild($result,$topic).";";	
		$s_SQLCommand = "call JO_news_relate_getlist('$kq','$tag','$key')";
		
		$rs_result = DataProvider::executeSQL($s_SQLCommand);
		return $rs_result; 
	}
	function JO_news_get_detail($key,$topic){
		$result=test();
		$kq=";".getchild($result,$topic).";";	
	$s_SQLCommand = "call JO_news_get_detail($key);";
	
	$rs_result = DataProvider::executeSQL($s_SQLCommand);
	return $rs_result; 
	}	
	function JO_newsold_getlist($topic,$key){
		$result=test();
		$kq=";".getchild($result,$topic).";";
		$s_SQLCommand = "call JO_newsold_getlist('$kq',$key);";
		$rs_result = DataProvider::executeSQL($s_SQLCommand);
		return $rs_result; 
	}	
			 ?>

            <div class="mar8i"></div>
            <div style="margin-left: 0px;background:#1a1a1a;" class="bar_720i">
                
                    <div class="JO_h1i">K-Pop News</div>
                    <div class="mar8i"></div>
                    <div style="float: left;margin-bottom: 8px; width: 704px;">
                    <?php
					if(isset($chude)){
					$result=JO_news_get_detail($chude,1);
					if($result->num_rows){
					$result_news=$result->fetch_array();
					?>
                        <div class="JO_kpopnews_item720i">
                       
                            <div class="JO_newimg">
                                <img src="<?=JO_UNconvertHTMLentities($result_news['image'])?>"/>
                            </div>
                          
                            <div class="mar8i"></div>
                            <div class="JO_newscontenti">
                                <b><?=JO_UNconvertHTMLentities($result_news['title'])?></b><br/>
                                <i class="JO_ii"><?=$result_news['insert']?></i><br/>
                               	<?=JO_UNconvertHTMLentities($result_news['description'])?>
                                <div class="JO_kpop_relatedi">
                                    <div class="mar8i"></div>
                                    <ul class="nav_relatedi" style="padding-bottom: 0px;">
                       			 <?php 
									
									$topic=isset($_GET['type'])?$_GET['type']:"''";
									$result_news_relate=JO_news_relate_getlist($topic,$result_news['tag'],$result_news['key']);
									if($result_news_relate!=NULL)
									while($row_news_relate=$result_news_relate->fetch_array()){							
									 ?>
                                        <li><a href="?JO_unit=008_KPopNews_Detail&SO_chude=<?=JO_UNconvertHTMLentities($row_news_relate['key'])?>&SO_relate=<?=JO_UNconvertHTMLentities($row_news_relate['tag'])?>&type=<?=$topic?>"><?=JO_UNconvertHTMLentities($row_news_relate['title'])?></a></li>									
								<?php } ?>
                                    </ul>
                                </div>
                            </div>
                            <div class="JO_kpopnew_maincontenti">   
                                <?=html_entity_decode(JO_UNconvertHTMLentities($result_news['content']), ENT_QUOTES,'utf-8');?>

                            </div>

                        </div>
                    </div>
                    <?
					}else echo 'ko có tin tức này';}else{
					echo 'ko có tin tuc ở phần này';	
					}
					if(isset($chude)){
					if($result->num_rows){
					$article_id=$chude;
					include('JO_011_commentOBJ.php');}}
					?>
                    <div class="JO_h1i">Other News</div>
                    <div class="mar8i"></div>
                    <div style="float: left;margin-bottom: 8px; width: 704px;">
                        <ul class="nav_relatedi" style="padding-bottom: 0px;padding: 0px 8px 0px 0px;">
                        <?php 
										if($result->num_rows)
									
									while($results=$result->fetch_array()){							
							 		?>
                            <li><a href="?JO_unit=008_KPopNews_Detail&SO_chude=<?=$results['key']?>"><i class="JO_ii"><?=$results['insert']?></i><?=JO_UNconvertHTMLentities($results['title'])?></a></li>
                            <?php }?>
                        </ul>
                    </div>
                
            </div>

            
        </div>
    